﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="tabPrimary.ascx.cs" Inherits="WebForm_EmpData_tabPrimary" %>
<script runat="server">
    protected void ddlTitle_DataBinding(object sender, EventArgs e)
    {
        (sender as ListControl).DataValueField = "Value";
        (sender as ListControl).DataTextField = "Text";
        (sender as ListControl).DataSource = CodeManager.Current.GetData("EmpData", "Title");
        
        if (fv.CurrentMode == FormViewMode.Edit)
        {
            (sender as ListControl).Text = Eval("Title", "");
        }
    }

    protected void ddlEmpLevel_DataBinding(object sender, EventArgs e)
    {
        (sender as ListControl).DataValueField = "Value";
        (sender as ListControl).DataTextField = "Text";
        (sender as ListControl).DataSource = CodeManager.Current.GetData("EmpData", "EmpLevel");

        if (fv.CurrentMode == FormViewMode.Edit)
        {
            (sender as ListControl).Text = Eval("EmpLevel", "");
        }
    }

    protected void ddlOrgID_DataBinding(object sender, EventArgs e)
    {
        var db = new DB();
        var dt = db.Execute("SELECT * FROM OrgData ");

        LocManager.Current.Translate(dt, "OrgData", "OrgName");

        (sender as ListControl).DataValueField = "OrgID";
        (sender as ListControl).DataTextField = "OrgName";
        (sender as ListControl).DataSource = dt;

        if (fv.CurrentMode == FormViewMode.Edit)
        {
            (sender as ListControl).Text = Eval("OrgID", "");
        }        
    }

    protected void ddlWorkGroupID_DataBinding(object sender, EventArgs e)
    {
        var db = new DB();
        var dt = db.Execute("SELECT * FROM WorkGroup WHERE CompID=@CompID ", new DBParameter("CompID", OrgManager.Current.CurrentComp));

        LocManager.Current.Translate(dt, "WorkGroup", "WorkGroupName");

        (sender as ListControl).DataValueField = "WorkGroupID";
        (sender as ListControl).DataTextField = "WorkGroupName";
        (sender as ListControl).DataSource = dt;

        if (fv.CurrentMode == FormViewMode.Edit)
        {
            (sender as ListControl).Text = Eval("WorkGroupID", "");
        }
    }    
</script>
<table>
    <tr>
        <td class="label">
            <asp:Localize ID="Localize1" runat="server" Text="<%$Resources: EmpData, EmpID %>"></asp:Localize>            
        </td>
        <td class="text">
            <asp:TextBox ID="txtEmpID" runat="server" Text='<%# Eval("EmpID") %>'></asp:TextBox>
            <My:InputTip ID="tipEmpID" runat="server" Must="true" Text="<%$Resources:tipEmpID.Text   %>" />
        </td>
    </tr>
    <tr>
        <td class="label">
            <asp:Localize ID="Localize6" runat="server" Text="<%$Resources: EmpData, EmpName %>"></asp:Localize>
        </td>
        <td class="text">
            <asp:TextBox ID="txtEmpName" runat="server" Text='<%# LocManager.Current.GetText("EmpData","EmpName",Eval("EmpID", "")) %>'></asp:TextBox>
            <My:InputTip ID="InputTip1" runat="server" Must="true" />
        </td>
    </tr>
    <tr>
        <td class="label">
            <asp:Localize ID="Localize8" runat="server" Text="<%$Resources: EmpData, NTAccount %>"></asp:Localize>
        </td>
        <td class="text">
            <asp:TextBox ID="txtNTAccount" runat="server" Text='<%# Eval("NTAccount") %>'></asp:TextBox>
            <My:InputTip ID="InputTip2" runat="server" Must="true" />
        </td>
    </tr>
    <tr>
        <td class="label">
            <asp:Localize ID="Localize9" runat="server" Text="<%$Resources: OrgData, OrgName %>"></asp:Localize>
        </td>
        <td class="text">
            <My:MyDropDownList ID="ddlOrgID" runat="server" OnDataBinding="ddlOrgID_DataBinding"
                EmptyText="<%$Resources: Form, ddl.EmptyText %>">
            </My:MyDropDownList>
            <My:InputTip ID="InputTip3" runat="server" Must="true" />
        </td>
    </tr>
    <tr>
        <td class="label">
            <asp:Localize ID="Localize7" runat="server" Text="<%$Resources: EmpData, Title %>"></asp:Localize>
        </td>
        <td class="text">
            <My:MyDropDownList ID="ddlTitle" runat="server" OnDataBinding="ddlTitle_DataBinding"
                EmptyText="<%$Resources: Form, ddl.EmptyText %>">
            </My:MyDropDownList>
            <My:InputTip ID="InputTip4" runat="server" Must="true" />
        </td>
    </tr>
    <tr>
        <td class="label">
            <asp:Localize ID="Localize2" runat="server" Text="<%$Resources: EmpData, EmpLevel %>"></asp:Localize>
        </td>
        <td class="text">
            <My:MyDropDownList ID="ddlEmpLevel" runat="server" OnDataBinding="ddlEmpLevel_DataBinding"
                EmptyText="<%$Resources: Form, ddl.EmptyText %>">
            </My:MyDropDownList>
            <My:InputTip ID="InputTip5" runat="server" Must="true" />
        </td>
    </tr>
    <tr>
        <td class="label">
            <asp:Localize ID="Localize3" runat="server" Text="<%$Resources: WorkGroup, WorkGroupID %>"></asp:Localize>
        </td>
        <td class="text">
            <My:MyDropDownList ID="ddlWorkGroupID" runat="server" OnDataBinding="ddlWorkGroupID_DataBinding"
                EmptyText="<%$Resources: Form, ddl.EmptyText %>">
            </My:MyDropDownList>
            <My:InputTip ID="InputTip6" runat="server" Must="true" />
        </td>
    </tr>
</table>
